﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(ICartItemRepository))]
    public partial class EntityRepositories : ICartItemRepository
    {
        public IQueryable<ICartItem> CartItems
        {
            get { return this.DataWriterContext.CartItems; }
        }

        public void Delete(ICartItem cartItem)
        {
            if (cartItem != null)
            {
                var item = this.DataWriterContext.CartItems.Where(i => i.Id == cartItem.Id).FirstOrDefault();
                if (item != null)
                {
                    this.DataWriterContext.CartItems.DeleteOnSubmit(item);
                }
            }
        }
    }
}
